package com.qingci;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.messaging.handler.annotation.MessageMapping;
import org.springframework.messaging.simp.SimpMessagingTemplate;
import org.springframework.stereotype.Controller;

@Controller
@EnableDiscoveryClient
@SpringBootApplication
public class FooApplication {

    private static SimpMessagingTemplate simpMessagingTemplate;

    @Autowired
    public void setSimpMessagingTemplate(SimpMessagingTemplate simpMessagingTemplate) {
        FooApplication.simpMessagingTemplate = simpMessagingTemplate;
    }

    public static void main(String[] args) {
        SpringApplication.run(FooApplication.class, args);
    }

    @MessageMapping("/bar")
    public void bar(String message) {
        System.out.println("bar message = " + message);
    }

    @MessageMapping("/foo")
    public void foo(String message) {
        System.out.println("foo message = " + message);
    }
}
